function getlocation(force = false) {
	return new Promise((resolve, rej) => {
		const now = Date.now();
		const last = uni.getStorageSync('last') || 0;
		let interval = 10 * 60 * 1000; // 10分钟
		const location = uni.getStorageSync('location')
		if (now - last > interval || location?.lat == 0 || force) {
			let geocode = false;
			uni.getLocation({
				type: 'gcj02',
				// #ifdef APP-PLUS
				geocode: true, // app中返回位置信息
				// #endif
				success: (res) => {
					console.log('定位成了', res)
					uni.setStorageSync('location', {
						lng: res.longitude,
						lat: res.latitude,
						// #ifdef APP-PLUS
						...res.address
						// #endif

						// #ifndef APP-PLUS
						"country": "中国",
						"province": "河南省",
						"city": "郑州市",
						"district": "二七区",
						"street": "长江路",
						"streetNum": "186号",
						"poiName": "亚星时代广场",
						"cityCode": "0371"
						// #endif
					})
					uni.setStorageSync('last', now)
					resolve({
						lng: res.longitude,
						lat: res.latitude,
						// #ifdef APP-PLUS
						...res.address
						// #endif
						// #ifndef APP-PLUS
						"country": "中国",
						"province": "河南省",
						"city": "郑州市",
						"district": "二七区",
						"street": "长江路",
						"streetNum": "186号",
						"poiName": "亚星时代广场",
						"cityCode": "0371"
						// #endif
					})
				},
				fail: (err) => {
					console.log('定位失败', err)
					uni.setStorageSync('location', {
						lng: 0,
						lat: 0,
						// #ifdef APP-PLUS
						"country": "",
						"province": "",
						"city": "",
						"district": "",
						"street": "",
						"streetNum": "",
						"poiName": "",
						"cityCode": ""
						// #endif
					})
					resolve({
						lng: 0,
						lat: 0,
						// #ifdef APP-PLUS
						"country": "",
						"province": "",
						"city": "",
						"district": "",
						"street": "",
						"streetNum": "",
						"poiName": "",
						"cityCode": ""
						// #endif
					})
				}
			});
		} else {
			console.log('返回的本地缓存')
			resolve(location)
		}
	})
}

export default getlocation;